package com.datastructures.search;

/**
 * 线性查找
 * @author MaoLin Wang
 * @date 2019/10/3112:43
 */
public class SeqSeaerch {
    public static void main(String[] args) {
        int[] arr={1,9,11,-1,22,44};
        int i = seqSearch(arr, 11);
        if (1 ==-1){
            System.out.println("未找到");
        }else {
            System.out.println("下标为"+i);
        }
    }

    public static int seqSearch(int[] arr,int value){
        for (int x=0;x<arr.length;x++){
            if (arr[x]==value){
                return x;
            }
        }
        return -1;

    }
}
